﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    public delegate void Say();
    class Program
    {
        static void Main(string[] args)
        {
            var str = ConfigSection.Get("testUrl");
            Console.WriteLine(str);
            Console.ReadKey();
            TestFunc(a =>
            {
                if (a == "3")
                {
                    return "33";
                }
                else
                {
                    return "55";
                }

            });
            //Func匿名委托
            Func<double, double> NameAction = delegate(double i)
            {
                return i * i; ;
            };
            //lamdba表达式
            Func<double, double> JsAction = s => s * s;
            Console.WriteLine(JsAction(6));
            Action<double, double> JJAction = delegate(double i, double s)
            {
                Console.WriteLine(i * s);
            };
            JJAction(10, 4);
            Action<double, double> JBAction = (s, i) =>
            {
                Console.WriteLine(s * i);
            };
            JBAction(20, 9);


            Console.WriteLine(NameAction(8));

            #region 多播
            Say sa = msg1;
            sa += msg2;
            sa += msg3;
            sa -= msg4;
            sa();
            #endregion


            Console.Read();
        }

        public static void msg1()
        {
            Console.WriteLine("你好1");
        }
        public static void msg2()
        {
            Console.WriteLine("你好2");
        }
        public static void msg3()
        {
            Console.WriteLine("你好3");
        }
        public static void msg4()
        {
            Console.WriteLine("你好4");
        }





        public static void TestFunc(Func<string, string> func)
        {
            Console.WriteLine(func("3"));
        }

        private static bool Gogo(int a)
        {
            return a == 5;
        }


        //private static void TestFunc(Func<string> go)
        //{
        //    //Console.WriteLine("a");
        //}
    }

    public class Book
    {
        public string Name { get; set; }
    }

}
